package com.bingo.listener;

import com.bingo.event.MyTestEvent;
import com.bingo.event.MyTestEventPubLisher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author 25452
 */
@Component
public class MyAnnotationListener {

	@Order(-1)
	@EventListener
	public void listener1(MyTestEvent event) {
		System.out.println("注解监听器1:" + event.getMsg());
	}

	@Order(-2)
	@EventListener
	@Async("asyncThreadPool")
	public void listener2(MyTestEvent event) {
		try {
			String name = Thread.currentThread().getName();
			System.out.println("current Thread name:"+name);
			Thread.sleep(30000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("注解监听器2:" + event.getMsg());
	}
}
